﻿using System.Collections.Generic;
using System.Linq;
using NBlog.Web.Application.Service.Entity;
using NBlog.Web.Controllers;

namespace NBlog.Web.Application.Infrastructure
{
    public static class EnumerableExtensions
    {
        public static List<HomeController.EntrySummaryModel> AsEntrySummaryModels(this IEnumerable<BaseEntity> source)
        {
            return source.Select(e => new HomeController.EntrySummaryModel
                {
                    Key = e.Slug,
                    Title = e.Title,
                    Date = e.DateCreated.ToDateString()
                }).ToList();
        }
    }
}